/**
 * Created with IntelliJ IDEA.
 * Description:x的平方根
 * User: wangxin
 * Date: 2025-02-04
 * Time: 20:47
 */
public class Test2 {
    public int mySqrt(int x) {
        int l = 0,r = x,ans = -1;
        while(l <= r){
            int mid = l + (r-l)/2;
            if((long)mid*mid <= x){
                ans = mid;
                l = mid+1;
            }else{
                r = mid-1;
            }
        }
        return ans;
    }
}
